function ajax(url){
  const p = new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest()
    xhr.open(GET, url, true)
    xhr.onreadystatechange = function() {
      if(xhr.readyState === 4){
        if(xhr.status === 200){
          resolve(xhr.response)
        }else if (xhr.status === 404){
          reject(new Error('404'))
        }
      }
    }
    xhr.send()
  })
  return p
}
